/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#include "InitialRenameClassCheker.h"

#include "Debug.h"
#include "DexClass.h"
#include "Show.h"
#include "Walkers.h"

namespace redex_properties {

void InitialRenameClassCheker::run_checker(DexStoresVector& stores,
                                           ConfigFiles& /* conf */,
                                           PassManager& /* mgr */,
                                           bool established) {
  if (!established) {
    return;
  }
  const auto& scope = build_class_scope(stores);
  walk::classes(scope, [&](const DexClass* cls) {
    always_assert_log(cls->rstate.is_renamable_initialized() ||
                          cls->rstate.is_generated(),
                      "[%s] is not generated by Redex, and its renamable "
                      "status has not been initialized yet!\n",
                      SHOW(cls));
  });
}

} // namespace redex_properties

namespace {
static redex_properties::InitialRenameClassCheker s_checker;
} // namespace
